﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<QianBuo.Lottery.Web.Models.Play.PlayTypeModel>" %>
<div >
    <div id="play_inputpanel">
        <table border="0" cellpadding="0" cellspacing="5" class="play_play_input">
            <tr class="tr_number" id="p10000">
                <td class="head">十位</td>
                <td class="number">大</td>
                <td class="number">小</td>
                <td class="number">单</td>
                <td class="number">双</td>
            </tr>
            <tr class="tr_number" id="p1000" >
                <td class="head">个位</td>
                <td class="number">大</td>
                <td class="number" >小</td>
                <td class="number" >单</td>
                <td class="number" >双</td>
            </tr>
           <tr id="playinfo">
                <td colspan="58" style=" text-align:left">
                    <%=Model.Remark %>
                </td>
            </tr>
            <tr>
                <td colspan="8" id="sumcount">
                    注数:<font color="red">0</font>
                </td>
                <td colspan="10" align="left">
                    <input type="button" name="bet_play_btnadd" onclick="DaXiaoDanShuan.addScheme()" id="bet_play_btnadd" value="添加" class="bet_play_btnadd" />
                </td>
            </tr>
        </table>
        <script type="text/javascript">
            var __playid=<%=Model.PlayID %>;
            $(document).ready(showWinInfo);
            function showWinInfo(){
                var pwin = Site.Lottery.Bet.GetPlayTypeWinMoney(function(item){ return item.PlayTypeID == __playid;});
                if(pwin != null)
                    $('<span><%=string.IsNullOrEmpty(Model.Remark) ? "" : "，" %>'+"奖金:<font color='red'>"+pwin.WinMoney+"元</font></span>").appendTo($("#playinfo td"));
                else
                    window.setTimeout(showWinInfo,500);
            }
            DaXiaoDanShuan={};


            DaXiaoDanShuan.ChooseNumber=[];

            DaXiaoDanShuan.ChooseNumber['p10000'] = '';
            DaXiaoDanShuan.ChooseNumber['p1000'] = '';

            DaXiaoDanShuan.PlayID=<%=Model.ID %>;
            DaXiaoDanShuan.PlayName='<%=Model.Name%>';

            Site.Lottery.Bet.SetCurrentPlay(DaXiaoDanShuan.PlayID, DaXiaoDanShuan.PlayName);

            $(".play_play_input .number").click(function () {
                var item = $(this);
                var id = item.parent().attr("id");
                if (item.is(".select")) {
                    item.removeClass("select");
                    DaXiaoDanShuan.ChooseNumber[id] = DaXiaoDanShuan.ChooseNumber[id].replace(item.text(),'');
                }
                else {
                    item.addClass("select");
                    DaXiaoDanShuan.ChooseNumber[id] = DaXiaoDanShuan.ChooseNumber[id] + item.text();
                }

                //alert(DaXiaoDanShuan.ChooseNumber['p10000'].length+','+DaXiaoDanShuan.ChooseNumber['p1000'].length+','+DaXiaoDanShuan.ChooseNumber['p100'].length);

                var count = DaXiaoDanShuan.ChooseNumber['p10000'].length * DaXiaoDanShuan.ChooseNumber['p1000'].length ;

                $(".play_play_input #sumcount font").html(count);
            });

            DaXiaoDanShuan.addScheme = function() {
                for (var n in DaXiaoDanShuan.ChooseNumber) {
                    if (DaXiaoDanShuan.ChooseNumber[n].length == 0) {
                        alert('号码选择不正确！');
                        return;
                    }

//                    DaXiaoDanShuan.ChooseNumber[n] = DaXiaoDanShuan.ChooseNumber[n].split('').sort().join('');
                    var list = DaXiaoDanShuan.ChooseNumber[n].split('');
                    DaXiaoDanShuan.ChooseNumber[n] = '';
                    var str = '大小单双';
                    for (var i = 0; i < str.length; i++) {
                        for (var j = 0; j < list.length; j++) {
                            if (str.substring(i, i + 1) == list[j]) {
                                DaXiaoDanShuan.ChooseNumber[n] += list[j];
                            }
                        }
                    }
                }

                var number = DaXiaoDanShuan.ChooseNumber['p10000'] + ',' + DaXiaoDanShuan.ChooseNumber['p1000'];
                var count = DaXiaoDanShuan.ChooseNumber['p10000'].length * DaXiaoDanShuan.ChooseNumber['p1000'].length;

                if (Site.Lottery.Bet)
                    Site.Lottery.Bet.AddPlayItem(DaXiaoDanShuan.PlayID, DaXiaoDanShuan.PlayName, number, count, 1)

                DaXiaoDanShuan.ClearNumber();
            };

            DaXiaoDanShuan.ClearNumber = function() {
                DaXiaoDanShuan.ChooseNumber['p10000'] = '';
                DaXiaoDanShuan.ChooseNumber['p1000'] = '';
                $(".play_play_input #sumcount font").html('0');
                var numbers = $('.play_play_input').find('.number');
                numbers.each(function() {
                    $(this).removeClass("select");
                });
            };

        </script>
    </div>
</div>


